home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Programming / tek / task / createport.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-05-12  |  878 b   |  44 lines

  1.  
  2. #include "tek/exec.h"
  3. #include "tek/kn/exec.h"
  4.  
  5. /* 
  6. **    TEKlib
  7. **    (C) 2001 TEK neoscientists
  8. **    all rights reserved.
  9. **
  10. **    TMSGPORT *TCreatePort(TAPTR task, TTAGITEM *tags)
  11. **
  12. **    create message port.
  13. **
  14. **    tags:
  15. **        TTask_MMU        - mmu used for allocating the message port. default: task's heap mmu.
  16. **
  17. */
  18.  
  19. TPORT *TCreatePort(TAPTR task, TTAGITEM *tags)
  20. {
  21.     if (task)
  22.     {
  23.         TAPTR mmu = TGetTagValue(TTask_MMU, &((TTASK *) task)->heapmmu, tags);
  24.         TPORT *msgport = TMMUAllocHandle(mmu, (TDESTROYFUNC) TDestroyPort, sizeof(TPORT));
  25.         if (msgport)
  26.         {
  27.             msgport->signal = TAllocSignal(task, 0);
  28.             if (msgport->signal)
  29.             {
  30.                 if (kn_initlock(&msgport->lock))
  31.                 {
  32.                     msgport->proxy = TNULL;
  33.                     msgport->sigtask = task;
  34.                     TInitList(&msgport->msglist);
  35.                     return msgport;
  36.                 }
  37.                 TFreeSignal(task, msgport->signal);
  38.             }
  39.             TMMUFreeHandle(msgport);
  40.         }
  41.     }
  42.     return TNULL;
  43. }
  44.